home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Utilities / MView / adjacency.fx next >
Encoding:
Text File  |  2004-09-27  |  10.6 KB  |  404 lines

  1. //
  2. // Standard texture effect
  3. // Copyright {c} 2000 Microsoft Corporation. All rights reserved.
  4. //
  5.  
  6. vector vClr;   // color 
  7.  
  8. vector vScl;
  9.  
  10. matrix mWld;    // World
  11. matrix mTot;     // Total 
  12.  
  13. matrix mWd1;     
  14. matrix mWd2;     
  15. matrix mWd3;     
  16. matrix mWd4;     
  17. matrix mWd5;     
  18. matrix mWd6;     
  19. matrix mWd7;     
  20. matrix mWd8;     
  21. matrix mWd9;     
  22. matrix mWd10;     
  23. matrix mWd11;     
  24. matrix mWd12;     
  25. matrix mWd13;     
  26. matrix mWd14;     
  27. matrix mWd15;     
  28. matrix mWd16;     
  29. matrix mWd17;     
  30. matrix mWd18;     
  31. matrix mWd19;     
  32. matrix mWd20;     
  33. matrix mWd21;     
  34. matrix mWd22;     
  35. matrix mWd23;     
  36. matrix mWd24;     
  37. matrix mWd25;     
  38. matrix mWd26;     
  39. matrix mWd27;     
  40. matrix mWd28;    
  41.  
  42. float4x3 mWorlds[28];
  43.  
  44. Vertexshader vDif = 
  45.     decl
  46.     {
  47.                 stream 0;
  48.  
  49.                 float v0[3];
  50.                 float v1[4];
  51.  
  52.                 float v2[3];
  53.                 float v3[4];
  54.  
  55.                 float v4[3];
  56.                 float v5[4];
  57.  
  58.                 float v6[3];
  59.     }
  60.     asm
  61.     {
  62.     vs.1.1
  63.  
  64.     dcl_position v0;
  65.     dcl_blendweight v1;
  66.  
  67.     dcl_texcoord0 v2;
  68.     dcl_texcoord1 v3;
  69.     dcl_texcoord2 v4;
  70.     dcl_texcoord3 v5;
  71.     dcl_texcoord4 v6;
  72.  
  73.     //skin the point in v0 using v1 weights
  74.     m4x3 r0.xyz,v0,c0
  75.     m4x3 r1.xyz,v0,c4
  76.     m4x3 r2.xyz,v0,c8
  77.     m4x3 r3.xyz,v0,c12
  78.  
  79.     mul r0.xyz,r0.xyz,v1.xxxx
  80.     mad r0.xyz,r1.xyz,v1.yyyy,r0
  81.     mad r0.xyz,r2.xyz,v1.zzzz,r0
  82.     mad r0.xyz,r3.xyz,v1.wwww,r0
  83.  
  84.     // move into avg register
  85.     mul r8.xyz, r0.xyz, v6.xxxx
  86.  
  87.     //skin the point in v2 using v3 weights
  88.     m4x3 r0.xyz,v2,c0
  89.     m4x3 r1.xyz,v2,c4
  90.     m4x3 r2.xyz,v2,c8
  91.     m4x3 r3.xyz,v2,c12
  92.  
  93.     mul r0.xyz,r0.xyz,v3.xxxx
  94.     mad r0.xyz,r1.xyz,v3.yyyy,r0
  95.     mad r0.xyz,r2.xyz,v3.zzzz,r0
  96.     mad r0.xyz,r3.xyz,v3.wwww,r0
  97.  
  98.     // add into avg register
  99.     mad r8.xyz, r0.xyz,v6.yyyy,r8
  100.  
  101.     //skin the point in v4 using v5 weights
  102.     m4x3 r0.xyz,v4,c0
  103.     m4x3 r1.xyz,v4,c4
  104.     m4x3 r2.xyz,v4,c8
  105.     m4x3 r3.xyz,v4,c12
  106.  
  107.     mul r0.xyz,r0.xyz,v5.xxxx
  108.     mad r0.xyz,r1.xyz,v5.yyyy,r0
  109.     mad r0.xyz,r2.xyz,v5.zzzz,r0
  110.     mad r0.xyz,r3.xyz,v5.wwww,r0
  111.  
  112.     // add into avg register
  113.     mad r8.xyz, r0.xyz,v6.zzzz,r8
  114.  
  115.     mov r8.w,c20.x
  116.     m4x4 oPos,r8,c16
  117.  
  118.     mov oD0,c22
  119.     };
  120.  
  121.  
  122. struct VS_INPUT_NONINDEXED
  123. {
  124.     float4 Position1 : POSITION;
  125.     float4 Weights1 : BLENDWEIGHT;
  126.     float4 Position2 : TEXCOORD0;
  127.     float4 Weights2 : TEXCOORD1;
  128.     float4 Position3 : TEXCOORD2;
  129.     float4 Weights3 : TEXCOORD3;
  130.     float3 Barycentric : TEXCOORD4;
  131. };
  132.  
  133. struct VS_INPUT_INDEXED
  134. {
  135.     float4 Position1 : POSITION;
  136.     float4 Weights1 : BLENDWEIGHT;
  137.     int4 BlendIndices1 : BLENDINDICES;
  138.     float4 Position2 : TEXCOORD0;
  139.     float4 Weights2 : TEXCOORD1;
  140.     int4 BlendIndices2 : TEXCOORD2;
  141.     float4 Position3 : TEXCOORD3;
  142.     float4 Weights3 : TEXCOORD4;
  143.     int4 BlendIndices3 : TEXCOORD5;
  144.     float3 Barycentric : TEXCOORD6;
  145. };
  146.  
  147. struct VS_OUTPUT
  148. {
  149.     float4 Position : POSITION;
  150.     float4 Color : COLOR;
  151. };
  152.  
  153.  
  154.  
  155. VS_OUTPUT NonIndexed(VS_INPUT_NONINDEXED Input)
  156. {
  157.     float3 Position;
  158.     float3 Position1;
  159.     float3 Position2;
  160.     float3 Position3;
  161.     VS_OUTPUT Output;
  162.  
  163.  
  164.     Position1 = mul(Input.Position1, (float4x3)mWd1) * Input.Weights1.xxx;
  165.     Position1 += mul(Input.Position1, (float4x3)mWd2) * Input.Weights1.yyy;
  166.     Position1 += mul(Input.Position1, (float4x3)mWd3) * Input.Weights1.zzz;
  167.     Position1 += mul(Input.Position1, (float4x3)mWd4) * Input.Weights1.www;
  168.  
  169.     Position2 = mul(Input.Position2, (float4x3)mWd1) * Input.Weights2.xxx;
  170.     Position2 += mul(Input.Position2, (float4x3)mWd2) * Input.Weights2.yyy;
  171.     Position2 += mul(Input.Position2, (float4x3)mWd3) * Input.Weights2.zzz;
  172.     Position2 += mul(Input.Position2, (float4x3)mWd4) * Input.Weights2.www;
  173.  
  174.     Position3 = mul(Input.Position3, (float4x3)mWd1) * Input.Weights3.xxx;
  175.     Position3 += mul(Input.Position3, (float4x3)mWd2) * Input.Weights3.yyy;
  176.     Position3 += mul(Input.Position3, (float4x3)mWd3) * Input.Weights3.zzz;
  177.     Position3 += mul(Input.Position3, (float4x3)mWd4) * Input.Weights3.www;
  178.  
  179.     Position = Position1 * Input.Barycentric.x + Position2 * Input.Barycentric.y + Position3 * Input.Barycentric.z;
  180.     
  181.     Output.Color = vClr;
  182.     Output.Position = mul(float4(Position, 1.0), mTot);
  183.  
  184.     return Output;    
  185. }
  186.  
  187. VS_OUTPUT Indexed(VS_INPUT_INDEXED Input)
  188. {
  189.     float3 Position;
  190.     float3 Position1;
  191.     float3 Position2;
  192.     float3 Position3;
  193.     VS_OUTPUT Output;
  194.     float4 BlendIndices;
  195.  
  196.     BlendIndices = D3DCOLORtoUBYTE4(Input.BlendIndices1);
  197.  
  198.     Position1 = mul(Input.Position1, (float4x3)mWorlds[BlendIndices.x]) * Input.Weights1.xxx;
  199.     Position1 += mul(Input.Position1, (float4x3)mWorlds[BlendIndices.y]) * Input.Weights1.yyy;
  200.     Position1 += mul(Input.Position1, (float4x3)mWorlds[BlendIndices.z]) * Input.Weights1.zzz;
  201.     Position1 += mul(Input.Position1, (float4x3)mWorlds[BlendIndices.w]) * Input.Weights1.www;
  202.  
  203.     BlendIndices = D3DCOLORtoUBYTE4(Input.BlendIndices2);
  204.  
  205.     Position2 = mul(Input.Position2, (float4x3)mWorlds[BlendIndices.x]) * Input.Weights2.xxx;
  206.     Position2 += mul(Input.Position2, (float4x3)mWorlds[BlendIndices.y]) * Input.Weights2.yyy;
  207.     Position2 += mul(Input.Position2, (float4x3)mWorlds[BlendIndices.z]) * Input.Weights2.zzz;
  208.     Position2 += mul(Input.Position2, (float4x3)mWorlds[BlendIndices.w]) * Input.Weights2.www;
  209.  
  210.     BlendIndices = D3DCOLORtoUBYTE4(Input.BlendIndices3);
  211.  
  212.     Position3 = mul(Input.Position3, (float4x3)mWorlds[BlendIndices.x]) * Input.Weights3.xxx;
  213.     Position3 += mul(Input.Position3, (float4x3)mWorlds[BlendIndices.y]) * Input.Weights3.yyy;
  214.     Position3 += mul(Input.Position3, (float4x3)mWorlds[BlendIndices.z]) * Input.Weights3.zzz;
  215.     Position3 += mul(Input.Position3, (float4x3)mWorlds[BlendIndices.w]) * Input.Weights3.www;
  216.  
  217.     Position = Position1 * Input.Barycentric.x + Position2 * Input.Barycentric.y + Position3 * Input.Barycentric.z;
  218.         
  219.     Output.Color = vClr;
  220.     Output.Position = mul(float4(Position, 1.0), mTot);
  221.  
  222.     return Output;    
  223. }
  224.  
  225.  
  226. technique T111
  227. {
  228.     pass P0
  229.     {
  230.         ColorVertex  = FALSE;
  231.  
  232.         ColorOp[0]   = Disable;
  233.         AlphaOp[0]   = Disable;
  234.  
  235.         VertexShader = compile vs_1_1 NonIndexed();
  236. #if 0
  237.         VertexShader = <vDif>;
  238.  
  239.         VertexShaderConstant[0] = <mWd1>;
  240.         VertexShaderConstant[4] = <mWd2>;
  241.         VertexShaderConstant[8] = <mWd3>;
  242.         VertexShaderConstant[12] = <mWd4>;
  243.         VertexShaderConstant[16] = <mTot>;
  244.         VertexShaderConstant[20] = {1.0f, 0.0f, 0.0f, 0.0f};
  245.         VertexShaderConstant[21] = <vScl>;
  246.         VertexShaderConstant[22] = <vClr>;
  247. #endif
  248.     }
  249. }
  250.  
  251. Vertexshader vIndexed = 
  252.     decl
  253.     {
  254.                 stream 0;
  255.  
  256.                 float v0[3];
  257.                 float v1[4];
  258.                 d3dcolor v2[1];
  259.  
  260.                 float v3[3];
  261.                 float v4[4];
  262.                 d3dcolor v5[1];
  263.  
  264.                 float v6[3];
  265.                 float v7[4];
  266.                 d3dcolor v8[1];
  267.  
  268.                 float v9[3];
  269.     }
  270.     asm
  271.     {
  272.     vs.1.1
  273.  
  274.     dcl_position v0;
  275.     dcl_blendweight v1;
  276.     dcl_blendindices v2;
  277.  
  278.     dcl_texcoord0 v3;
  279.     dcl_texcoord1 v4;
  280.     dcl_texcoord2 v5;
  281.     dcl_texcoord3 v6;
  282.     dcl_texcoord4 v7
  283.     dcl_texcoord5 v8;
  284.     dcl_texcoord6 v9;
  285.  
  286.     // need to add dcl! here!!! UNDONE UNDONE
  287.  
  288.     // Compensate for lack of UBYTE4 on Geforce3
  289.     mul r8,v2.zyxw,c4.wwww
  290.     
  291.     mov a0.x,r8.x
  292.     m4x3 r0.xyz,v0,c[a0.x + 9]
  293.     mov a0.x,r8.y
  294.     m4x3 r1.xyz,v0,c[a0.x + 9]
  295.     mov a0.x,r8.z
  296.     m4x3 r2.xyz,v0,c[a0.x + 9]
  297.     mov a0.x,r8.w
  298.     m4x3 r3.xyz,v0,c[a0.x + 9]
  299.  
  300.     mul r0.xyz,r0.xyz,v1.xxxx
  301.     mad r0.xyz,r1.xyz,v1.yyyy,r0
  302.     mad r0.xyz,r2.xyz,v1.zzzz,r0
  303.     mad r0.xyz,r3.xyz,v1.wwww,r0
  304.  
  305.     // move into avg register
  306.     mul r7.xyz, r0.xyz, v9.xxxx
  307.  
  308.     // Compensate for lack of UBYTE4 on Geforce3
  309.     mul r8,v5.zyxw,c4.wwww
  310.     
  311.     mov a0.x,r8.x
  312.     m4x3 r0.xyz,v3,c[a0.x + 9]
  313.     mov a0.x,r8.y
  314.     m4x3 r1.xyz,v3,c[a0.x + 9]
  315.     mov a0.x,r8.z
  316.     m4x3 r2.xyz,v3,c[a0.x + 9]
  317.     mov a0.x,r8.w
  318.     m4x3 r3.xyz,v3,c[a0.x + 9]
  319.  
  320.     mul r0.xyz,r0.xyz,v4.xxxx
  321.     mad r0.xyz,r1.xyz,v4.yyyy,r0
  322.     mad r0.xyz,r2.xyz,v4.zzzz,r0
  323.     mad r0.xyz,r3.xyz,v4.wwww,r0
  324.  
  325.     // add into avg register
  326.     mad r7.xyz, r0.xyz,v9.yyyy,r7
  327.  
  328.     // Compensate for lack of UBYTE4 on Geforce3
  329.     mul r8,v8.zyxw,c4.wwww
  330.     
  331.     mov a0.x,r8.x
  332.     m4x3 r0.xyz,v6,c[a0.x + 9]
  333.     mov a0.x,r8.y
  334.     m4x3 r1.xyz,v6,c[a0.x + 9]
  335.     mov a0.x,r8.z
  336.     m4x3 r2.xyz,v6,c[a0.x + 9]
  337.     mov a0.x,r8.w
  338.     m4x3 r3.xyz,v6,c[a0.x + 9]
  339.  
  340.     mul r0.xyz,r0.xyz,v7.xxxx
  341.     mad r0.xyz,r1.xyz,v7.yyyy,r0
  342.     mad r0.xyz,r2.xyz,v7.zzzz,r0
  343.     mad r0.xyz,r3.xyz,v7.wwww,r0
  344.  
  345.     // add into avg register
  346.     mad r7.xyz, r0.xyz,v9.zzzz,r7
  347.  
  348.     mov r7.w,c4.x
  349.     m4x4 oPos,r7,c0
  350.  
  351.     mov oD0,c5
  352.     };
  353.  
  354. technique Indexed
  355. {
  356.     pass P0
  357.     {
  358.         ColorVertex = FALSE;
  359.  
  360.         ColorOp[0]   = Disable;
  361.         AlphaOp[0]   = Disable;
  362. #if 0
  363.         VertexShader = <vIndexed>;
  364.  
  365.         VertexShaderConstant[0] = <mTot>;
  366.         VertexShaderConstant[4] = { 1.0f, 0.0f, 0.0f, 765.01f };
  367.         VertexShaderConstant[5] = <vClr>;
  368.         VertexShaderConstant[6] = <vScl>;
  369.  
  370.         VertexShaderConstant3[9] = <mWd1>;
  371.         VertexShaderConstant3[12] = <mWd2>;
  372.         VertexShaderConstant3[15] = <mWd3>;
  373.         VertexShaderConstant3[18] = <mWd4>;
  374.         VertexShaderConstant3[21] = <mWd5>;
  375.         VertexShaderConstant3[24] = <mWd6>;
  376.         VertexShaderConstant3[27] = <mWd7>;
  377.         VertexShaderConstant3[30] = <mWd8>;
  378.         VertexShaderConstant3[33] = <mWd9>;
  379.         VertexShaderConstant3[36] = <mWd10>;
  380.         VertexShaderConstant3[39] = <mWd11>;
  381.         VertexShaderConstant3[42] = <mWd12>;
  382.         VertexShaderConstant3[45] = <mWd13>;
  383.         VertexShaderConstant3[48] = <mWd14>;
  384.         VertexShaderConstant3[51] = <mWd15>;
  385.         VertexShaderConstant3[54] = <mWd16>;
  386.         VertexShaderConstant3[57] = <mWd17>;
  387.         VertexShaderConstant3[60] = <mWd18>;
  388.         VertexShaderConstant3[63] = <mWd19>;
  389.         VertexShaderConstant3[66] = <mWd20>;
  390.         VertexShaderConstant3[69] = <mWd21>;
  391.         VertexShaderConstant3[72] = <mWd22>;
  392.         VertexShaderConstant3[75] = <mWd23>;
  393.         VertexShaderConstant3[78] = <mWd24>;
  394.         VertexShaderConstant3[81] = <mWd25>;
  395.         VertexShaderConstant3[84] = <mWd26>;
  396.         VertexShaderConstant3[87] = <mWd27>;
  397.         VertexShaderConstant3[90] = <mWd28>;
  398. #else
  399.         VertexShader = compile vs_1_1 Indexed();
  400. #endif
  401.     }
  402. }
  403.  
  404.